package com.fourthGroup.controller;

import com.fourthGroup.model.Activity;
import com.fourthGroup.service.ActivityService;
import com.fourthGroup.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/activity")
@Slf4j
public class ActivityController {

    @Autowired
    private ActivityService activityService;

    @PostMapping
    public Result<Activity> createActivity(@RequestBody Activity activity) {
        log.info("创建活动: {}", activity);
        return activityService.createActivity(activity);
    }

    @GetMapping
    public Result<List<Activity>> listActivities() {
        log.info("查询活动列表");
        return activityService.listActivities();
    }

    @GetMapping("/{id}")
    public Result<Activity> getActivity(@PathVariable Long id) {
        log.info("查询活动详情: {}", id);
        return activityService.getActivity(id);
    }

    @PutMapping
    public Result<Activity> updateActivity(@RequestBody Activity activity) {
        log.info("更新活动: {}", activity);
        return activityService.updateActivity(activity);
    }
} 